from django.db import models

# Create your models here.
# 创建订单信息表模型类
class CartInfo(models.Model):
    id = models.AutoField(primary_key=True)
    quantity = models.IntegerField('购买数量')
    commodityinfo_id = models.IntegerField('商品id')
    user_id = models.IntegerField('用户id')

    def __str__(self):
        return str(self.id)

    class Meta:
        verbose_name = '购物车'
        verbose_name_plural = '购物车'

# 定义订单状态数据类型
STATE = (
    ('待支付','待支付'),
    ('已支付','已支付'),
    ('发货中','发货中'),
    ('已签收','已签收'),
    ('退货中','退货中')
)
# 创建的订单信息表模型类
class OrderInfo(models.Model):
    id = models.AutoField(primary_key=True)
    price = models.FloatField('订单总价')
    created = models.DateField('创建时间', auto_now_add=True)
    user_id = models.IntegerField('用户id')
    state = models.CharField('订单状态', max_length=20, choices=STATE)   # choices设置字段可选值

    def __str__(self):
        return str(self.id)

    class Meta:
        verbose_name = '购物车'
        verbose_name_plural = '购物车'
